package ar.edu.unicen.pladema.vc1.practico3;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;

import ar.edu.unicen.pladema.main.SWTUtils;
import ar.edu.unicen.pladema.ui.model.points.ScreenPoint;
import ar.edu.unicen.pladema.ui.mouseListener.VCMouseMoveListener;
import ar.edu.unicen.pladema.ui.panel.AbstractPanel;
import ar.edu.unicen.pladema.ui.panel.options.IMoveIt;
import ar.edu.unicen.pladema.ui.panel.options.IPaintIt;
import ar.edu.unicen.pladema.ui.panel.options.IZoomIt;
import ar.edu.unicen.pladema.ui.panel.options.POP3E1;
import ar.edu.unicen.pladema.vc1.model.GraphicAttributes;

public class P3Enunciado1 extends AbstractPanel implements IPaintIt, IMoveIt, IZoomIt {
	private Composite lienzo;
	private P3Enunciado1Drawer listener;
	private POP3E1 pOpciones;
	private GraphicAttributes graphicAttributes; 

	public P3Enunciado1(Composite parent) {
		super(parent);
	}

	@Override
	protected void createWidgets() {
		graphicAttributes = new GraphicAttributes();
		graphicAttributes
			.add(GraphicAttributes.CLIENT_WIDTH, 300)
			.add(GraphicAttributes.CLIENT_HEIGHT, 300)
			.add("RCXmin",0).add("RCXmax",0)
			.add("RCYmin",0).add("RCYmax",0)
			.add("RCZmin",0).add("RCZmax",0)
			.add("XLight", "2")
			.add("YLight", "2")
			.add("ZLight", "2");
			//.add(GraphicAttributes.FILE_NAME, "/home/kache/Documentos/facultad/VC1/Practico 3: Objetos, iluminación y transformaciones/objetos/esfera.sur");
		
		listener = new P3Enunciado1Drawer(graphicAttributes);
		pOpciones = new POP3E1(this, this, graphicAttributes, listener);
		lienzo = new Composite(this, SWT.BORDER);
		

		lienzo.addPaintListener(listener);
		VCMouseMoveListener mouseMove = new VCMouseMoveListener(this, this, this);
		lienzo.addMouseListener(mouseMove);
		lienzo.addMouseMoveListener(mouseMove);
		lienzo.addMouseWheelListener(mouseMove);
	}
	@Override
	protected void layoutWidgets() {
		setLayout(new FormLayout());
		FormData fdLienzo = SWTUtils.createFullLeftFormData(pOpciones);
		fdLienzo.bottom = new FormAttachment(SWTUtils.MAX_FORMDATA_COORD);
		lienzo.setLayoutData(fdLienzo);

		pOpciones.setLayoutData(SWTUtils.createRightFormData(5));
	}

	@Override
	public void doPaint() {
		lienzo.redraw();
	}

	@Override
	public void doMove(ScreenPoint from, ScreenPoint to) {
		listener.movePoint(from, to);
	}

	@Override
	public void doZoom(ScreenPoint from, ScreenPoint to) {
		
	}

	@Override
	public void doZoom(boolean in) {
		listener.doZoom(in);
	}

}
